package com.babster631;

import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.Item;
import net.minecraft.item.ItemSpade;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;

public class thunderspade extends ItemSpade 
{
        public thunderspade(int par1, EnumToolMaterial et) 
        {
                super(par1, et);
                this.setCreativeTab(CreativeTabs.tabTools);
        }
	    public void registerIcons(IconRegister iconReg)
	    {
	        itemIcon = iconReg.registerIcon("babster631modbase:thunderspade.fw");
	    }
	    public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
	    {
	    	if (!par2World.isRemote)
	    	{
	    		par3EntityPlayer.posY+=.5f;
	    		MovingObjectPosition cor=par3EntityPlayer.rayTrace(100, 1);
	    		if (cor!=null)
	    		{
		    		if (par2World.getBlockId(cor.blockX, cor.blockY, cor.blockZ)==Block.dirt.blockID)
		    		{
		    			par2World.setBlock(cor.blockX, cor.blockY, cor.blockZ, Block.grass.blockID);
		    			par1ItemStack.damageItem(1, par3EntityPlayer);
		    		}
	    		}
	    		par3EntityPlayer.posY-=.5f;
	    	}
			return par1ItemStack;	
	    }

}
